package o;

import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.mp4.MdtaMetadataEntry;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.Metadata.Entry;
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
import com.google.android.exoplayer2.metadata.id3.InternalFrame;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
import java.nio.ByteBuffer;

public final class afa {
    private static final int ʻ = anr.ᐝ("wrt");
    private static final int ʻॱ = anr.ᐝ("cpil");
    private static final int ʼ = anr.ᐝ("alb");
    private static final int ʼॱ = anr.ᐝ("soco");
    private static final int ʽ = anr.ᐝ("too");
    private static final int ʽॱ = anr.ᐝ("soal");
    private static final int ʾ = anr.ᐝ("rtng");
    private static final int ʿ = anr.ᐝ("soar");
    private static final int ˈ = anr.ᐝ("soaa");
    private static final int ˉ = anr.ᐝ("pgap");
    private static final int ˊ = anr.ᐝ("trk");
    private static final String[] ˊˊ = new String[]{"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover", "Contemporary Christian", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "Jpop", "Synthpop"};
    private static final int ˊˋ = anr.ᐝ("tvsh");
    private static final int ˊॱ = anr.ᐝ("covr");
    private static final int ˊᐝ = anr.ᐝ("sosn");
    private static final int ˋ = anr.ᐝ("nam");
    private static final int ˋˊ = anr.ᐝ("----");
    private static final int ˋॱ = anr.ᐝ("disk");
    private static final int ˎ = anr.ᐝ("cmt");
    private static final int ˏ = anr.ᐝ("day");
    private static final int ˏॱ = anr.ᐝ("grp");
    private static final int ͺ = anr.ᐝ("gen");
    private static final int ॱ = anr.ᐝ("ART");
    private static final int ॱˊ = anr.ᐝ("gnre");
    private static final int ॱˋ = anr.ᐝ("trkn");
    private static final int ॱˎ = anr.ᐝ("aART");
    private static final int ॱॱ = anr.ᐝ("lyr");
    private static final int ॱᐝ = anr.ᐝ("sonm");
    private static final int ᐝ = anr.ᐝ("com");
    private static final int ᐝॱ = anr.ᐝ("tmpo");

    public static Format ˎ(int i, Format format, @Nullable Metadata metadata, @Nullable Metadata metadata2, aec o_aec) {
        if (i == 1) {
            if (o_aec.ˎ()) {
                format = format.ˋ(o_aec.ˏ, o_aec.ॱ);
            }
            if (metadata != null) {
                return format.ˏ(metadata);
            }
            return format;
        } else if (i != 2 || metadata2 == null) {
            return format;
        } else {
            for (int i2 = 0; i2 < metadata2.ˋ(); i2++) {
                Entry ˋ = metadata2.ˋ(i2);
                if (ˋ instanceof MdtaMetadataEntry) {
                    MdtaMetadataEntry mdtaMetadataEntry = (MdtaMetadataEntry) ˋ;
                    if ("com.android.capture.fps".equals(mdtaMetadataEntry.ˏ) && mdtaMetadataEntry.ॱ == 23) {
                        try {
                            format = format.ˏ(ByteBuffer.wrap(mdtaMetadataEntry.ˊ).asFloatBuffer().get()).ˏ(new Metadata(mdtaMetadataEntry));
                        } catch (NumberFormatException e) {
                            amz.ˏ("MetadataUtil", "Ignoring invalid framerate");
                        }
                    }
                }
            }
            return format;
        }
    }

    @Nullable
    public static Entry ˊ(anc o_anc) {
        int ॱᐝ = o_anc.ॱᐝ() + o_anc.ˋ();
        int ॱᐝ2 = o_anc.ॱᐝ();
        int i = (ॱᐝ2 >> 24) & 255;
        Entry ˏ;
        if (i == 169 || i == 253) {
            i = 16777215 & ॱᐝ2;
            try {
                if (i == ˎ) {
                    ˏ = ˏ(ॱᐝ2, o_anc);
                    return ˏ;
                } else if (i == ˋ || i == ˊ) {
                    ˏ = ॱ(ॱᐝ2, "TIT2", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ᐝ || i == ʻ) {
                    ˏ = ॱ(ॱᐝ2, "TCOM", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ˏ) {
                    ˏ = ॱ(ॱᐝ2, "TDRC", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ॱ) {
                    ˏ = ॱ(ॱᐝ2, "TPE1", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ʽ) {
                    ˏ = ॱ(ॱᐝ2, "TSSE", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ʼ) {
                    ˏ = ॱ(ॱᐝ2, "TALB", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ॱॱ) {
                    ˏ = ॱ(ॱᐝ2, "USLT", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ͺ) {
                    ˏ = ॱ(ॱᐝ2, "TCON", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                } else if (i == ˏॱ) {
                    ˏ = ॱ(ॱᐝ2, "TIT1", o_anc);
                    o_anc.ˋ(ॱᐝ);
                    return ˏ;
                }
            } finally {
                o_anc.ˋ(ॱᐝ);
            }
        } else if (ॱᐝ2 == ॱˊ) {
            ˏ = ˋ(o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˋॱ) {
            ˏ = ˋ(ॱᐝ2, "TPOS", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ॱˋ) {
            ˏ = ˋ(ॱᐝ2, "TRCK", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ᐝॱ) {
            ˏ = ˏ(ॱᐝ2, "TBPM", o_anc, true, false);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ʻॱ) {
            ˏ = ˏ(ॱᐝ2, "TCMP", o_anc, true, true);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˊॱ) {
            ˏ = ˎ(o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ॱˎ) {
            ˏ = ॱ(ॱᐝ2, "TPE2", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ॱᐝ) {
            ˏ = ॱ(ॱᐝ2, "TSOT", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ʽॱ) {
            ˏ = ॱ(ॱᐝ2, "TSO2", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ʿ) {
            ˏ = ॱ(ॱᐝ2, "TSOA", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˈ) {
            ˏ = ॱ(ॱᐝ2, "TSOP", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ʼॱ) {
            ˏ = ॱ(ॱᐝ2, "TSOC", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ʾ) {
            ˏ = ˏ(ॱᐝ2, "ITUNESADVISORY", o_anc, false, false);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˉ) {
            ˏ = ˏ(ॱᐝ2, "ITUNESGAPLESS", o_anc, false, true);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˊᐝ) {
            ˏ = ॱ(ॱᐝ2, "TVSHOWSORT", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˊˋ) {
            ˏ = ॱ(ॱᐝ2, "TVSHOW", o_anc);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        } else if (ॱᐝ2 == ˋˊ) {
            ˏ = ˊ(o_anc, ॱᐝ);
            o_anc.ˋ(ॱᐝ);
            return ˏ;
        }
        amz.ˊ("MetadataUtil", "Skipped unknown metadata entry: " + aeu.ˏ(ॱᐝ2));
        o_anc.ˋ(ॱᐝ);
        return null;
    }

    @Nullable
    public static MdtaMetadataEntry ॱ(anc o_anc, int i, String str) {
        while (true) {
            int ˋ = o_anc.ˋ();
            if (ˋ >= i) {
                return null;
            }
            int ॱᐝ = o_anc.ॱᐝ();
            if (o_anc.ॱᐝ() == aeu.ͺˎ) {
                int ॱᐝ2 = o_anc.ॱᐝ();
                int ॱᐝ3 = o_anc.ॱᐝ();
                ˋ = ॱᐝ - 16;
                byte[] bArr = new byte[ˋ];
                o_anc.ˎ(bArr, 0, ˋ);
                return new MdtaMetadataEntry(str, bArr, ॱᐝ3, ॱᐝ2);
            }
            o_anc.ˋ(ˋ + ॱᐝ);
        }
    }

    @Nullable
    private static TextInformationFrame ॱ(int i, String str, anc o_anc) {
        int ॱᐝ = o_anc.ॱᐝ();
        if (o_anc.ॱᐝ() == aeu.ͺˎ) {
            o_anc.ˎ(8);
            return new TextInformationFrame(str, null, o_anc.ʻ(ॱᐝ - 16));
        }
        amz.ˏ("MetadataUtil", "Failed to parse text attribute: " + aeu.ˏ(i));
        return null;
    }

    @Nullable
    private static CommentFrame ˏ(int i, anc o_anc) {
        int ॱᐝ = o_anc.ॱᐝ();
        if (o_anc.ॱᐝ() == aeu.ͺˎ) {
            o_anc.ˎ(8);
            String ʻ = o_anc.ʻ(ॱᐝ - 16);
            return new CommentFrame("und", ʻ, ʻ);
        }
        amz.ˏ("MetadataUtil", "Failed to parse comment attribute: " + aeu.ˏ(i));
        return null;
    }

    @Nullable
    private static Id3Frame ˏ(int i, String str, anc o_anc, boolean z, boolean z2) {
        int min;
        int ˏ = ˏ(o_anc);
        if (z2) {
            min = Math.min(1, ˏ);
        } else {
            min = ˏ;
        }
        if (min < 0) {
            amz.ˏ("MetadataUtil", "Failed to parse uint8 attribute: " + aeu.ˏ(i));
            return null;
        } else if (z) {
            return new TextInformationFrame(str, null, Integer.toString(min));
        } else {
            return new CommentFrame("und", str, Integer.toString(min));
        }
    }

    @Nullable
    private static TextInformationFrame ˋ(int i, String str, anc o_anc) {
        int ॱᐝ = o_anc.ॱᐝ();
        if (o_anc.ॱᐝ() == aeu.ͺˎ && ॱᐝ >= 22) {
            o_anc.ˎ(10);
            ॱᐝ = o_anc.ॱॱ();
            if (ॱᐝ > 0) {
                String str2 = "" + ॱᐝ;
                int ॱॱ = o_anc.ॱॱ();
                if (ॱॱ > 0) {
                    str2 = str2 + "/" + ॱॱ;
                }
                return new TextInformationFrame(str, null, str2);
            }
        }
        amz.ˏ("MetadataUtil", "Failed to parse index/count attribute: " + aeu.ˏ(i));
        return null;
    }

    @Nullable
    private static TextInformationFrame ˋ(anc o_anc) {
        int ˏ = ˏ(o_anc);
        String str = (ˏ <= 0 || ˏ > ˊˊ.length) ? null : ˊˊ[ˏ - 1];
        if (str != null) {
            return new TextInformationFrame("TCON", null, str);
        }
        amz.ˏ("MetadataUtil", "Failed to parse standard genre code");
        return null;
    }

    @Nullable
    private static ApicFrame ˎ(anc o_anc) {
        int ॱᐝ = o_anc.ॱᐝ();
        if (o_anc.ॱᐝ() == aeu.ͺˎ) {
            int ˎ = aeu.ˎ(o_anc.ॱᐝ());
            String str = ˎ == 13 ? "image/jpeg" : ˎ == 14 ? "image/png" : null;
            if (str == null) {
                amz.ˏ("MetadataUtil", "Unrecognized cover art flags: " + ˎ);
                return null;
            }
            o_anc.ˎ(4);
            byte[] bArr = new byte[(ॱᐝ - 16)];
            o_anc.ˎ(bArr, 0, bArr.length);
            return new ApicFrame(str, null, 3, bArr);
        }
        amz.ˏ("MetadataUtil", "Failed to parse cover art attribute");
        return null;
    }

    @Nullable
    private static Id3Frame ˊ(anc o_anc, int i) {
        int i2 = -1;
        int i3 = -1;
        String str = null;
        String str2 = null;
        while (o_anc.ˋ() < i) {
            int ˋ = o_anc.ˋ();
            int ॱᐝ = o_anc.ॱᐝ();
            int ॱᐝ2 = o_anc.ॱᐝ();
            o_anc.ˎ(4);
            if (ॱᐝ2 == aeu.ˏͺ) {
                str2 = o_anc.ʻ(ॱᐝ - 12);
            } else if (ॱᐝ2 == aeu.ͺˏ) {
                str = o_anc.ʻ(ॱᐝ - 12);
            } else {
                if (ॱᐝ2 == aeu.ͺˎ) {
                    i2 = ॱᐝ;
                    i3 = ˋ;
                }
                o_anc.ˎ(ॱᐝ - 12);
            }
        }
        if (str2 == null || str == null || i3 == -1) {
            return null;
        }
        o_anc.ˋ(i3);
        o_anc.ˎ(16);
        return new InternalFrame(str2, str, o_anc.ʻ(i2 - 16));
    }

    private static int ˏ(anc o_anc) {
        o_anc.ˎ(4);
        if (o_anc.ॱᐝ() == aeu.ͺˎ) {
            o_anc.ˎ(8);
            return o_anc.ʽ();
        }
        amz.ˏ("MetadataUtil", "Failed to parse uint8 attribute value");
        return -1;
    }
}
